package com.ikangtai.shecare.common.baseView.recordButtonView;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;

import com.ikangtai.shecare.R;

/**
 * Created by Administrator on 2016/1/20.
 */
public class RecordSelectBUltraButton extends RecordSelectButton{

    private Context context;
    public static final int RECORD_BULTRA_SELECT_WHITE_BACKGROUND_COLOR = 0;
    public static final int RECORD_BULTRA_SELECT_PURPLE_BACKGROUND_COLOR = 1;
    public static final String RecordSelectBUltraButtonType="BULTRA";

    public RecordSelectBUltraButton(Context context){
        super(context);
        this.context=context;
        setType(RecordSelectBUltraButtonType);
    }
    public RecordSelectBUltraButton(Context context, AttributeSet attrs){
        super(context,attrs);
        this.context=context;
       this.backgroundColor = RECORD_BULTRA_SELECT_WHITE_BACKGROUND_COLOR;
    }

    @Override
    public void setColor(int backGroundColor) {
        super.setColor(backGroundColor);
    }

    @Override
    public void clickAction(View view) {
        RecordSelectBUltraButton recordBUltraYesBtn;
        RecordSelectBUltraButton recordBUltraNoBtn;
       if(null!=view){
           recordBUltraYesBtn=(RecordSelectBUltraButton)view.findViewById(R.id.record_b_ultra_btn_yes);
           recordBUltraNoBtn=(RecordSelectBUltraButton)view.findViewById(R.id.record_b_ultra_btn_no);

        if(backgroundColor == RECORD_BULTRA_SELECT_WHITE_BACKGROUND_COLOR||backgroundColor == RECORD_BULTRA_SELECT_PURPLE_BACKGROUND_COLOR){
            backgroundColor = RECORD_BULTRA_SELECT_PURPLE_BACKGROUND_COLOR;
            if(this.getId()==recordBUltraYesBtn.getId()){
                this.setBackground(getResources().getDrawable(R.drawable.record_b_ultra_button_pressed));
                this.setTextColor(Color.WHITE);
                recordBUltraNoBtn.setColor(RECORD_BULTRA_SELECT_WHITE_BACKGROUND_COLOR);
                recordBUltraNoBtn.setBackground(getResources().getDrawable(R.drawable.record_b_ultra_button_default));
                recordBUltraNoBtn.setTextColor(getResources().getColor(R.color.b_ultra_color));}

            if(this.getId()==recordBUltraNoBtn.getId()){
                this.setBackground(getResources().getDrawable(R.drawable.record_b_ultra_button_pressed));
                this.setTextColor(Color.WHITE);
                recordBUltraYesBtn.setColor(RECORD_BULTRA_SELECT_WHITE_BACKGROUND_COLOR);
                recordBUltraYesBtn.setBackground(getResources().getDrawable(R.drawable.record_b_ultra_button_default));
                recordBUltraYesBtn.setTextColor(getResources().getColor(R.color.b_ultra_color));
            }

        }
       }
    }

}
